﻿using Inovout.Repositories;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Security.Repositories
{
    public class FormsUserRepository : DataObjectRepository<FormsUser>
    {
        public FormsUser FindByEmail(string email)
        {
            var list = base.OpenSession().CreateCriteria<FormsUser>()
                .CreateCriteria("Membership", "membership")
                .Add(Restrictions.Eq("Membership.UserId", "FormsUser.Id").IgnoreCase())
                .Add(Restrictions.Eq("Membership.Email", email).IgnoreCase())
                .List<FormsUser>();
            return Single(list);
        }
    }
}
